package com.navinfo.platform.trip.common.arithmetic;

import com.navinfo.platform.trip.common.arithmetic.data.OuterStatisticData;
import com.navinfo.platform.trip.common.arithmetic.var.VarParkingPowerOn;
import com.navinfo.platform.trip.common.arithmetic.manager.AbstractArithmetic;
import com.navinfo.platform.trip.common.util.ArithmeticUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 停车通电算法
 * 输出：统计<br/>
 * @author web
 */
public class ParkingPowerOn extends AbstractArithmetic<VarParkingPowerOn> {

    private static Logger logger = LoggerFactory.getLogger(ParkingPowerOn.class);

    @Override
    public void calculate() {
//        废弃代码
//        VarParkingPowerOn var = getObj();
//        logger.debug("停车通电算法开始...");
//        //>>1 判断ACC状态
//        //>>1.1 若为开启状态，累计时长
//        Boolean status = drivingData.getCommonData().getAccStatus();
//        if(status != null && status == true){
//            var.setParkingPowerOnTime(var.getParkingPowerOnTime() + drivingData.getCommonData().getDffTime());
//        }
//        setObj(var);
//        logger.debug("停车通电算法结束.[terminalId:{}]", terminalId);
    }


    @Override
    public void collect(OuterStatisticData statisticDataOut) {
        statisticDataOut.setParkingPowerOnDuration(0);

        Object obj = drivingData.getStatisticData().get(this.getClass().getSimpleName());
        if(null!=obj && obj instanceof VarParkingPowerOn){
            VarParkingPowerOn var = (VarParkingPowerOn)obj;
            if (var.getParkingTime()>0 && var.getParkingPowerOnTime()>0
                    && var.getLastGpsTime()>0 && var.getLastGpsTime()> var.getParkingTime()
                    && getCommonData().getGpsTime()>var.getLastGpsTime()) {
                statisticDataOut.setParkingPowerOnDuration(ArithmeticUtils.timeMsToSecond(var.getParkingPowerOnTime()));
            }
        }
    }
}
